#include <iostream>
#include <vector>
using namespace std;

int const maxn = 10001;
bool vis[maxn];
int tim[maxn];
vector<vector<int> > graph;
int n, m, t = 0;

void dfs(int x)
{
	vis[x] = true;
	tim[x] = t++;
	cout << x+1 << "\n";
	int len = graph[x].size();
	bool flag = false;
	for (int i = 0; i < len; i++) {
		int v = graph[x][i];
		if (vis[v]) {
			if (tim[x] < tim[v])
				cout << v+1 << "\n" << x+1 << "\n";
		} else {
			flag = true;
			dfs(v);
			cout << x+1 << "\n";
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> m;
	graph.resize(n);
	for (int i = 0, x, y; i < m; i++) {
		cin >> x >> y;
		x--; y--;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	dfs(0);
}

